/*
 * @Author: sbotlp
 * @Email: sbotlp@sina.com
 * @Date: 2019-06-27 17:51:32
 * @LastEditTime: 2019-06-30 10:29:29
 * @Description: http://www.sbotlp.com.cn
 */
// tslint:disable-next-line:interface-over-type-literal
export type InternalStateType = {
  [key: string]: any
};
export class AppState {
  _state: InternalStateType = {};
  get state() {
    // return this._state = this._clone(this._state);
    return this._state;
  }

  set state(value) {
    throw new Error('do not mutate the `.state` directly');
  }

  get(prop?: any) {
    const state = this.state;
    return prop ? (state.hasOwnProperty(prop) ? state[prop] : null) : state;
  }

  set(prop: string, value: any) {
    return this._state[prop] = value;
  }
}
